package com.example.adminbase.service.imp;

import com.example.adminbase.dao.SysRolePermMapper;
import com.example.adminbase.domain.*;
import com.example.adminbase.service.AuthorizationService;
import com.github.pagehelper.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.Assert;
import org.springframework.util.StringUtils;

import java.util.List;

@Service
@Transactional
public class AuthorizationServiceImpl implements AuthorizationService {
    @Autowired
    private SysRolePermMapper sysRolePermMapper;

    @Override
    public void grantRolePerm(String roleId, List<String> permIds) {
        Assert.hasText(roleId, "roleId 不能为空");
        Assert.notNull(permIds, "permIds 不能为 null ");

        sysRolePermMapper.deleteWithRoleId(roleId);
        for (String permId :
                permIds) {
            if(StringUtils.hasText(permId)) {
                sysRolePermMapper.insert(new SysRolePerm(roleId, permId));
            }
        }
    }

    @Override
    public Page<SysUser> findUser(UserQueryParam queryParam) {
        return null;
    }

    @Override
    public void createUser(SysUser user) {

    }

    @Override
    public void editUser(SysUser user) {

    }

    @Override
    public void delUser(String userId) {

    }

    @Override
    public void modifyPassword(String userId, String password) {

    }

    @Override
    public List<SysDept> findSubordinate(String deptId) {
        return null;
    }

    @Override
    public void grantUserRoles(String userId, List<String> roleIds) {

    }

    @Override
    public Page<SysDept> findDept(QueryParam queryParam) {
        return null;
    }

    @Override
    public void createDept(SysDept sysDept) {

    }

    @Override
    public void editDept(SysDept sysDept) {

    }

    @Override
    public void delDept(String deptId) {

    }

}
